package kr.hkit.androidcomplete01.ch07;

import kr.hkit.androidcomplete01.ch07.DrawBitmap.MyView;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.os.Bundle;
import android.view.View;

public class Primitive2 extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		MyView vw = new MyView(this);
		setContentView(vw);
	}
	
	class MyView extends View{
		public MyView(Context context) {
			super(context);
		}
		
		public void onDraw(Canvas canvas){
			Paint pnt = new Paint();
			pnt.setColor(Color.LTGRAY);
			canvas.drawPaint(pnt);
			
			RectF r = new RectF(10,10,100,100);
			pnt.setColor(Color.RED);
			canvas.drawRoundRect(r, 10, 10, pnt);
			
			//타원
			r.set(110, 10, 150, 100);
			canvas.drawOval(r, pnt);
			
			//분홍색 반달
			pnt.setColor(Color.MAGENTA);
			r.set(10, 110, 200, 200);
			canvas.drawArc(r, 10, 150, false, pnt);
			
			//분홍색파이
			r.set(110,110,200,200);
			canvas.drawArc(r, 10, 150, true, pnt);
			
			//파란색 다각선
			pnt.setColor(Color.BLUE);
			float[] pts={10,210,50,250,50250,110,220};
			canvas.drawLines(pts, pnt);
			
			//검은색 점 3개
			pnt.setColor(Color.BLACK);
			float[] pts2={20,210,50,240,100,220};
			canvas.drawPoints(pts2, pnt);
		}
	}
	
}
